#include "Camera.hpp"

#include <iostream>

namespace demo
{
	
	// need desired resolution
Camera::Camera(uint32_t cameraId)
: videoCapture(std::make_unique<cv::VideoCapture>(cameraId))
{
	// TODO: throw exception? 
	// if not success, exit program
	if (videoCapture->isOpened() == false)  
	{
	std::cout << "Cannot open the video camera" << std::endl;
	} 
	if (videoCapture->isOpened() == true)  
	{
	std::cout << "opened camera successfully" << std::endl;
	} 
 
}

cv::Mat Camera::getNextFrame()
{
	cv::Mat frame;
	bool result = videoCapture->read(frame);
	
	// TODO: throw exception, or send exit signal
	if (!result) 
	{
		std::cout << "Video camera is disconnected" << std::endl; 
	}
	
	return frame;
}


} // namespace demo
